home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
oop_tp55.zip
/
LIST5_4.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1990-01-25
|
2KB
|
64 lines
{ Declarations from the interface section of Listing 3-1 }
DInput = object(Digital)
Setpoint : real;
Reading : real;
procedure Init( ATag : string;
ASetpoint : real;
AReading : real);
procedure PutReading( NewReading : real ); {should be virtual; }
procedure PutSetpoint( NewSetpoint : real );
end;
HiSwitch = object(DInput)
procedure PutReading( NewReading : real ); {should be virtual; }
end;
LoSwitch = object(DInput)
procedure PutReading( NewReading : real ); {should be virtual; }
end;
{ Procedure definitions from the implementation section of Listing 3-1 }
procedure DInput.Init( ATag : string;
ASetpoint : real;
AReading : real);
begin
Tag.Init( ATag );
DInput.PutSetpoint( ASetpoint );
PutReading( AReading );
end;
procedure DInput.PutReading( NewReading : real );
begin
writeln( 'If this prints, .PutReading should be virtual!' );
end;
procedure LoSwitch.PutReading( NewReading : real );
begin
Reading := NewReading;
if Reading <= Setpoint then
Status := true
else
Status := false;
end;
{procedure HiSwitch.Init( ATag : string;
ASetpoint : real;
AReading : real); } { DELETED! }
procedure HiSwitch.PutReading( NewReading : real );
begin
Reading := NewReading;
if Reading >= Setpoint then
Status := true
else
Status := false;
end;
{ Listing 5-4 }